import { useState, useImperativeHandle, forwardRef } from 'react';
import { Modal } from 'antd';

interface EditDialogProps {
  onOk?: any;
}

const EditDialog = forwardRef<any, EditDialogProps>(({ onOk = () => { } }, ref) => {
  const [dialogOpen, setDialogOpen] = useState(false)

  const open = () => {
    setDialogOpen(true);
  }
  const handleOk = () => {
    setDialogOpen(false);
  }
  const handleCancel = () => {
    setDialogOpen(false);
    onOk();
  }

  useImperativeHandle(ref, () => ({
    open,
    close: handleCancel,
  }));

  return (
    <Modal title="编辑弹框" open={dialogOpen} onOk={handleOk} onCancel={handleCancel} destroyOnClose>
      <p>Some contents...</p>
      <p>Some contents...</p>
      <p>Some contents...</p>
    </Modal>
  );
});

export default EditDialog;
